<div class="list">
<span class="txt"><a class="ajax2" href="javascript:void(0);"></a></span>
	<table cellspacing="0" cellpadding="0">
		<tr class="th">
			<th>ID</th>	
			<th>作品名称</th>
			<th>作品分类</th>
			<th>描述</th>	
			<th>操作</th>	
		</tr>
		<?php foreach($products as $item):?>
		<tr class="bg">
			<td width="60"><?php echo $item['id'];?></td>
			<td align="left"><?php echo $item['name'];?></td>
			<td><?php echo service_category::getNameByID($item['categoryID']);?></td>
			<td align="left"><?php echo mb_substr($item['description'],0,30,"utf8");?></td>
			<td class="odd" align="left">
				<a href="javascript:void(0);" id="<?php echo $item['id'];?>" class="ajax">编辑</a>&nbsp;|&nbsp;
				<a class='del' id="<?php echo $item['id'];?>" href='javascript:void(0);' >删除</a>&nbsp;|&nbsp;
				<a class='newp' id="<?php echo $item['id'];?>" href='javascript:void(0);' ><?php echo $item['newp']?'取消新品':'新品';?> </a>&nbsp;|&nbsp;
				<a class='isIndex' id="<?php echo $item['id'];?>" href='javascript:void(0);' ><?php echo $item['isIndex']?'取消热度':'热度';?> </a>
			</td>
		</tr>

		<?php endforeach;?>
		<tr>
			<td colspan="5" align="center"><?php echo $page;?></td>
		</tr>

	</table>
</div>
<script type="text/javascript">
$(document).ready(function(){
	$(".bg:odd").css("background-color","#EDEDED");
	$(".ajax").mouseover(function(){
        id = $(this).attr('id');
        $(".ajax").wBox({requestType: "ajax",title:"设计师作品修改",target:"<?php echo url('product/edit?id=')?>"+id});
    });
	$(".ajax2").mouseover(function(){
        id = $(this).attr('id');
        $(".ajax2").wBox({requestType: "ajax",title:"设计师作品添加",target:"<?php echo url('product/add')?>"});
    });
	$(".isIndex").click(function(){
		that = $(this);
		$.post("<?php echo url('product/recommend');?>",{id:that.attr('id')},function(data){
			if(data.s==1){
				var str = data.i?'取消置顶':'置顶';
				that.html(str);
			}
		});
		return false;
	});
	$(".newp").click(function(){
		that = $(this);
		$.post("<?php echo url('product/newp');?>",{id:that.attr('id')},function(data){
			if(data.s==1){
				var str = data.i?'取消新品':'新品';
				that.html(str);
			}
		});
		return false;
	});
	$(".del").click(function(){
		if(confirm("确认删除")){
			that = $(this);
			$.post("<?php echo url('product/del');?>",{id:that.attr('id')},function(data){
				if(data.s==1){
					that.parents('tr').remove();
				}else{
					alert(data.i);
				}
			});
		}
		return false;
		});	
});
</script>
